/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package trefliq.EJB.webservice;

import java.sql.Date;
import java.util.List;
import javax.annotation.security.RunAs;
import javax.ejb.EJB;
import javax.jws.WebService;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.naming.Context;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
import trefliq.EJB.entities.Movie;
import trefliq.EJB.security.SecurityPrincipal;
import trefliq.EJB.sessionbeans.MovieBean;

/**
 *
 * @author Adam Gojdas
 */
//@WebService(serviceName = "MovieWebService")
@Stateless()
public class MovieWebService {
    @EJB
    private MovieBean ejbRef;// Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Web Service Operation")

    @WebMethod(operationName = "getAllMovies")
    public List<Movie> getAllMovies() {
        return ejbRef.getAllMovies();
    }

    @WebMethod(operationName = "findMovie")
    public Movie findMovie(@WebParam(name = "id") Long id) {
        return ejbRef.findMovie(id);
    }

    @WebMethod(operationName = "findMovieByTitle")
    public Movie findMovieByTitle(@WebParam(name = "title") String title) {
        return ejbRef.findMovieByTitle(title);
    }

    @WebMethod(operationName = "UpdateMovie")
    public boolean UpdateMovie(@WebParam(name = "movie") Movie movie) {
        return ejbRef.UpdateMovie(movie);
    }

    @WebMethod(operationName = "DeleteMovie")
    public boolean DeleteMovie(@WebParam(name = "movie") Movie movie) {
        return ejbRef.DeleteMovie(movie);
    }

    @WebMethod(operationName = "CreateMovie")
    public Long CreateMovie(@WebParam(name = "title") String title, @WebParam(name = "desc") String desc, @WebParam(name = "rating") Long rating, @WebParam(name = "release") Date release) {
        return ejbRef.CreateMovie(title, desc, rating, release);
    }

    @WebMethod(operationName = "CreateMovie_1")
    @RequestWrapper(className = "CreateMovie_1")
    @ResponseWrapper(className = "CreateMovie_1Response")
    public Long CreateMovie(@WebParam(name = "title") String title, @WebParam(name = "desc") String desc, @WebParam(name = "rating") Long rating, @WebParam(name = "release") Date release, @WebParam(name = "ec") Context ec) {
        return ejbRef.CreateMovie(title, desc, rating, release, ec);
    }

    @WebMethod(operationName = "CreateMovie_2")
    @RequestWrapper(className = "CreateMovie_2")
    @ResponseWrapper(className = "CreateMovie_2Response")
    public Movie CreateMovie(@WebParam(name = "movie") Movie movie) {
        return ejbRef.CreateMovie(movie);
    }
    
}
